Beginning Android 4 Games Development by Mario Zechner Robert Green
Author:Mario Zechner, Robert Green
Language: eng
Format: epub, pdf
Publisher: Apress®
Published: 2011-12-06T16:00:00+00:00
Alpha Blending: I Can See Through You
Alpha blending in OpenGL ES is pretty easy to enable. We only need two method calls:
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
The first method call should be familiar: it just tells OpenGL ES that it should apply alpha blending to all triangles we render from this point on. The second method is a little bit more involved. It specifies how the source and destination color should be combined. If you remember what we discussed in Chapter 3, the way a source color and a destination color are combined is governed by a simple blending equation. The method glBlendFunc() just tells OpenGL ES which kind of equation to use. The preceding parameters specify that we want the source color to be mixed with the destination color exactly as specified in the blending equation in Chapter 3. This is equal to how the Canvas blended Bitmaps for us.
Blending in OpenGL ES is pretty powerful and complex, and there's a lot more to it. For our purposes, we can ignore all those details, though, and just use the preceding blending function whenever we want to blend our triangles with the framebuffer—the same way we blended Bitmaps with the Canvas.
The second question is where the source and destination colors come from. The latter is easy to explain: it's the color of the pixel in the framebuffer we are going to overwrite with the triangle we draw. The source color is actually a combination of two colors.
The vertex color: This is the color we either specify via glColor4f() for all vertices or on a per-vertex basis by adding a color attribute to each vertex.
The texel color: As mentioned before, a texel is a pixel from a texture. When our triangle is rendered with a texture mapped to it, OpenGL ES will mix the texel colors with the vertex colors for each pixel of a triangle.
Download
Beginning Android 4 Games Development by Mario Zechner Robert Green.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6535)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Kotlin in Action by Dmitry Jemerov(5066)
Odoo 15 Development Essentials - Fifth Edition by Daniel Reis & Greg Mader(3363)
Odoo 15 Development Essentials by Daniel Reis(2814)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2531)
Learning Angular - Second Edition by Christoffer Noring(2360)
Pride and Prejudice by Jane Austen(2350)
Mobile Forensics Cookbook by Igor Mikhaylov(2018)
Computers For Seniors For Dummies by Nancy C. Muir(1997)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1874)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1799)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1791)
1936941139 (N) by Bob Rosenthal(1732)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1727)
Hands-On Internet of Things with MQTT by Tim Pulver(1708)
Android App Development by Franceschi Hervé J.;(1705)
Ember.js in Action by Joachim Haagen Skeie(1689)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1656)
